﻿using System;
using System.ComponentModel;

namespace ExFlash.Records
{
    public class StrightEdgeRecord : ShapeRecord
    {
        public Boolean StraightFlag
        {
            get; 
            protected set;
        }

        [Browsable(false)]
        public Byte NumBits
        {
            get;
            protected set;
        }

        public Boolean GeneralLineFlag
        {
            get;
            protected set;
        }

        public Boolean VertLineFlag
        {
            get;
            protected set;
        }

        public int DeltaX
        {
            get;
            protected set;
        }

        public int DeltaY
        {
            get;
            protected set;
        }

        public StrightEdgeRecord()
            : base(true)
        {
        }

        public override void SwfDeserialize(BinaryBitReader reader)
        {
            StraightFlag = reader.ReadBoolean();
            
            NumBits = (Byte)reader.ReadUInt32(4);

            GeneralLineFlag = reader.ReadBoolean();

            if (!GeneralLineFlag)
            {
                VertLineFlag = reader.ReadBoolean();
            }

            if (GeneralLineFlag || !VertLineFlag)
            {
                DeltaX = reader.ReadInt32(NumBits + 2);
            }

            if (GeneralLineFlag || VertLineFlag)
            {
                DeltaY = reader.ReadInt32(NumBits + 2);
            }

            //BitUtil.AdvanceByteOffset(ref offset, BitOffset);
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }
    }
}
